const TeacherService = require('../services/TeacherService')

const TeacherController = {
  add: async (req, res) => {
    await TeacherService.add(req.body)
    res.send({
      ActionType: 'OK'
    })
  },

  delList: async (req, res) => {
    // console.log(req.params.username)
    await TeacherService.delList({
      username: req.params.username
    })
    res.send({
      ActionType: 'OK'
    })
  },

  getCourse: async (req, res) => {
    // console.log(req.params.username)
    const result = await TeacherService.getCourse({ username: req.params.username })
    res.send({
      ActionType: 'OK',
      data: result
    })
  },

  postCourse: async (req, res) => {
    // console.log(req.body.mycourses)
    await TeacherService.postCourse({ username: req.params.username }, { mycourses: req.body.mycourses })
    res.send({
      ActionType: 'OK'
    })
  }
}

module.exports = TeacherController
